package nancal.mp.db.mongo.entity.dev

import nbcp.base.db.annotation.Cn
import nbcp.base.db.annotation.DbEntityGroup
import nbcp.base.model.BaseMarkEntity
import org.springframework.data.mongodb.core.mapping.Document
import javax.sql.DataSource


data class TableMeta(
    var groupName: String = "",
    var remark: String = ""
)

@Cn("Mongo数据连接")
@Document
@DbEntityGroup("dev")
data class MongoConnection(
    @Cn("名称") var name: String = "",
    @Cn("Ip") var host: String = "",
    @Cn("端口") var port: Int = 27017,
    @Cn("用户名") var userName: String = "",
    @Cn("密码") var password: String = "",
    @Cn("数据库名") var dbName: String = "",
    @Cn("编码") var code: String = "",
    @Cn("备注") var remark: String = "",
    @Cn("表元数据定义") var tableMetas: MutableMap<String, TableMeta> = mutableMapOf(),
) : BaseMarkEntity() {

    val connectionUri: String
        get() {
            return "mongodb://${userName}:${password}@${host}:${port}/${dbName}?maxIdleTimeMS=3000"
        }
}